local hx__baiye = fk.CreateSkill {
  name = "hx__baiye",
  tags = { Skill.Compulsory },
}

hx__baiye:addEffect(fk.HpChanged, {
  anim_type = "defensive",
  can_trigger = function(self, event, target, player, data)
    return target == player and player:hasSkill(hx__baiye.name)
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    room:addPlayerMark(player, "@hx__qinggang", 1)
    if not player:hasSkill("hx__daoshu") and player:usedEffectTimes(self.name,Player.HistoryGame) > 0 then
        room:handleAddLoseSkills(player, "hx__daoshu", nil, true, false)
    end
    if not player:hasSkill("hx__moling") and player:usedEffectTimes(self.name,Player.HistoryGame) > 1 then
      room:handleAddLoseSkills(player, "hx__moling", nil, true, false)
    end
    if not player:hasSkill("hx__wuwo") and player:usedEffectTimes(self.name,Player.HistoryGame) > 2 then
      room:handleAddLoseSkills(player, "hx__wuwo", nil, true, false)
    end
  end,
})

hx__baiye:addEffect(fk.EnterDying, {
  can_trigger = function(self, event, target, player, data)
    return target == player and player:hasSkill(hx__baiye.name) and player:usedEffectTimes(self.name,Player.HistoryGame) == 0 and player.hp < 1
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    room:recover{
      who = player,
      num = 1 - player.hp,
      recoverBy = player,
      skillName = hx__baiye.name,
    }
    room:handleAddLoseSkills(player, "hx__xingjie", nil, true, false)
  end,
})

return hx__baiye